package com.akrc.blog.controller;

import com.akrc.blog.mapper.CategoryMapper;
import com.akrc.blog.model.Category;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CategoryController {
	final CategoryMapper categoryMapper;

	CategoryController(CategoryMapper categoryMapper) {
		this.categoryMapper = categoryMapper;
	}

	@GetMapping("/category/{id}")
	Category category(@PathVariable Integer id) {
		return categoryMapper.getByID(id);
	}

	@GetMapping("/categorylist")
	List<Category> categoryList() {
		return categoryMapper.categoryList();
	}
}
